import { BasicDelModel } from '../model/baseModel';
import { MenuSearchModel, MenuVOModel } from './model/menuModel';
import { defHttp } from '/@/utils/http/axios';

enum Api {
  BaseApi = '/sys/menu',
  // 新增增删改查按钮菜单接口地址
  SaveCrudMenuApi = '/sys/menu/add-crud-button',
  // 获取拥有子菜单的菜单主键集合接口地址
  GetMenuSelectTree = '/sys/menu/select-tree',
}

/**
 * @description: 获取菜单列表数据
 */
export const getMenuListApi = (data?: MenuSearchModel) => {
  return defHttp.post({ url: Api.BaseApi + '/list', data });
};

/**
 * @description: 获取菜单列表数据
 */
export const getMenuSelectTreeApi = () => {
  return defHttp.post({ url: Api.GetMenuSelectTree });
};

/**
 * @description: 新增菜单
 */
export const saveMenuApi = (data: MenuVOModel) => {
  return defHttp.post({ url: Api.BaseApi + '/add', data });
};

/**
 * @description: 新增增删改查按钮菜单
 */
export const saveCrudMenuApi = (data: MenuVOModel) => {
  return defHttp.post({ url: Api.SaveCrudMenuApi, data });
};

/**
 * @description: 修改菜单
 */
export const updateMenuApi = (data: MenuVOModel) => {
  return defHttp.post({ url: Api.BaseApi + '/edit', data });
};

/**
 * @description: 删除菜单
 */
export const delMenuApi = (ids: string[]) => {
  const data: BasicDelModel = {
    ids: ids
  }
  return defHttp.post({ url: Api.BaseApi + '/delete', data });
};
